package chj.Database;

import chj.Bookmanage.Badd;
import chj.Bookmanage.Bdelete;
import chj.Bookmanage.Bfind;
import chj.Bookmanage.Bupdate;

import javax.swing.*;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.Connection;

public class CDataBase {
    String url = "jdbc:mysql://localhost:3306/LibraryManagementSystem";
    String username = "root";
    String password = "123456";

    //连接数据库方法
    public Connection getConnection() throws SQLException {
        Connection con = (Connection) DriverManager.getConnection(url, username, password);
        return con;
    }
    //关闭数据库方法
    public void closeCon(Connection con) throws Exception {
        if(con != null) {
            con.close();
        }
    }
}
